c++;
i++;
}
- if (i != 8)
- {
- snprintf(tmp,sizeof(tmp),"\"%s\"\n",line);
- fprintf(stderr,"%s",tmp);
- }
return i;
}
}
// in buff we should now have something wich looks like a valid date starting with YYYYMMDD
ck = (char *)strptime(buff, "%Y%m%d", &filenamedate);
- if (((ck == NULL) || (*ck != '\0') )&&!(optdate))
- fatal(MYNAME ": Invalid date in filename \"%s\", try to set manually using \"optdate\" switch!\n", buff);
- else if (filenamedate.tm_year < 70)
- fatal(MYNAME ": Date \"%s\" is out of range (have to be 19700101 or later)!\n", buff);
- tx= mkgmtime(&filenamedate);
+ // if (((ck == NULL) || (*ck != '\0') )&&!(optdate))
+ // fatal(MYNAME ": Invalid date in filename \"%s\", try to set manually using \"date\" switch!\n", buff);
+ // /* else */ if (filenamedate.tm_year < 70)
+ // fatal(MYNAME ": Date \"%s\" is out of range (have to be 19700101 or later)!\n", buff);
+ // tx= mkgmtime(&filenamedate);
}
}
char tbuffer[64];
long_old=0;lat_old=0;
strftime(routename,sizeof(routename),"Tracklog %c",localtime(&tx));
+ struct tm tm2;
route = route_head_alloc();
route->rte_name=xstrdup(routename);
line=0;
while ((buff = gbfgetstr(fin)))
{
+ int nfields;
+ unsigned long microsecs;
if ((line == 0) && fin->unicode) cet_convert_init(CET_CHARSET_UTF8, 1);
str = buff = lrtrim(buff);
if (*buff == '\0') continue;
- if (gopal_check_line(buff)!=8)continue;
+ nfields = gopal_check_line(buff);
+ if ((nfields != 8) && (nfields != 11))continue;
+ // Old format. Hassle for date.
+ if ((nfields == 8) && (tx == 0)) {
+ // fatal(MYNAME ": Invalid date in filename \"%s\", try to set manually using \"date\" switch!\n", buff);
+ }
wpt = waypt_new();
column = -1;
switch(column)
{
case 0: /* "-" */ /* unknown fields for the moment */
- //sscanf(c, "%llu", &wpt->microseconds);
+ sscanf(c, "%lu", µsecs);
+ wpt->microseconds += microsecs % 1000000;
+ wpt->creation_time += microsecs / 1000000;
break;
case 1: /* Time UTC */
sscanf(c,"%lf",&hmsd);
case 8: /* number of sats */
sscanf(c, "%d", &wpt->sat);
break;
-
+ // Somewhere around mid/late 2009, these files started
+ // seeing 11 fields.
+ case 9:
+ memset(&tm2, 0, sizeof(tm2));
+ if (!strptime(c, "%Y%m%d", &tm2)) {
+ fatal ("Bad date '%s'.\n", c);
+ }
+ wpt->creation_time += mkgmtime(&tm2);
+ break;
+ case 10: // Unknown. Ignored.
+ case 11: // Bearing. Ignored.
+ break;
}
c = csv_lineparse(NULL, ",", "", column++);
}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<gpx
+ version="1.0"
+ creator="GPSBabel - http://www.gpsbabel.org"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://www.topografix.com/GPX/1/0"
+ xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd">
+<time>1970-01-01T00:00:00Z</time>
+<bounds minlat="50.307048000" minlon="8.231283000" maxlat="50.309623000" maxlon="8.232662000"/>
+<wpt lat="50.307048000" lon="8.232662000">
+ <ele>341.950000</ele>
+ <time>2009-11-06T21:32:32.528Z</time>
+ <name>RPT001</name>
+ <cmt>RPT001</cmt>
+ <desc>RPT001</desc>
+ <fix>2d</fix>
+ <sat>11</sat>
+ <hdop>0.766000</hdop>
+</wpt>
+<wpt lat="50.307475000" lon="8.232442000">
+ <ele>341.990000</ele>
+ <time>2009-11-06T21:32:33.529Z</time>
+ <name>RPT002</name>
+ <cmt>RPT002</cmt>
+ <desc>RPT002</desc>
+ <fix>2d</fix>
+ <sat>11</sat>
+ <hdop>0.766000</hdop>
+</wpt>
+<wpt lat="50.307902000" lon="8.232223000">
+ <ele>341.813000</ele>
+ <time>2009-11-06T21:32:34.530Z</time>
+ <name>RPT003</name>
+ <cmt>RPT003</cmt>
+ <desc>RPT003</desc>
+ <fix>2d</fix>
+ <sat>10</sat>
+ <hdop>0.832000</hdop>
+</wpt>
+<wpt lat="50.308332000" lon="8.232000000">
+ <ele>341.493000</ele>
+ <time>2009-11-06T21:32:35.531Z</time>
+ <name>RPT004</name>
+ <cmt>RPT004</cmt>
+ <desc>RPT004</desc>
+ <fix>2d</fix>
+ <sat>11</sat>
+ <hdop>0.766000</hdop>
+</wpt>
+<wpt lat="50.308765000" lon="8.231770000">
+ <ele>341.150000</ele>
+ <time>2009-11-06T21:32:36.532Z</time>
+ <name>RPT005</name>
+ <cmt>RPT005</cmt>
+ <desc>RPT005</desc>
+ <fix>2d</fix>
+ <sat>11</sat>
+ <hdop>0.766000</hdop>
+</wpt>
+<wpt lat="50.309198000" lon="8.231532000">
+ <ele>340.210000</ele>
+ <time>2009-11-06T21:32:37.533Z</time>
+ <name>RPT006</name>
+ <cmt>RPT006</cmt>
+ <desc>RPT006</desc>
+ <fix>2d</fix>
+ <sat>11</sat>
+ <hdop>0.766000</hdop>
+</wpt>
+<wpt lat="50.309623000" lon="8.231283000">
+ <ele>339.163000</ele>
+ <time>2009-11-06T21:32:38.534Z</time>
+ <name>RPT007</name>
+ <cmt>RPT007</cmt>
+ <desc>RPT007</desc>
+ <fix>2d</fix>
+ <sat>11</sat>
+ <hdop>0.766000</hdop>
+</wpt>
+<rte>
+ <name>Tracklog Wed Dec 31 18:00:00 1969</name>
+ <rtept lat="50.307048000" lon="8.232662000">
+ <ele>341.950000</ele>
+ <time>2009-11-06T21:32:32.528Z</time>
+ <name>RPT001</name>
+ <fix>2d</fix>
+ <sat>11</sat>
+ <hdop>0.766000</hdop>
+ </rtept>
+ <rtept lat="50.307475000" lon="8.232442000">
+ <ele>341.990000</ele>
+ <time>2009-11-06T21:32:33.529Z</time>
+ <name>RPT002</name>
+ <fix>2d</fix>
+ <sat>11</sat>
+ <hdop>0.766000</hdop>
+ </rtept>
+ <rtept lat="50.307902000" lon="8.232223000">
+ <ele>341.813000</ele>
+ <time>2009-11-06T21:32:34.530Z</time>
+ <name>RPT003</name>
+ <fix>2d</fix>
+ <sat>10</sat>
+ <hdop>0.832000</hdop>
+ </rtept>
+ <rtept lat="50.308332000" lon="8.232000000">
+ <ele>341.493000</ele>
+ <time>2009-11-06T21:32:35.531Z</time>
+ <name>RPT004</name>
+ <fix>2d</fix>
+ <sat>11</sat>
+ <hdop>0.766000</hdop>
+ </rtept>
+ <rtept lat="50.308765000" lon="8.231770000">
+ <ele>341.150000</ele>
+ <time>2009-11-06T21:32:36.532Z</time>
+ <name>RPT005</name>
+ <fix>2d</fix>
+ <sat>11</sat>
+ <hdop>0.766000</hdop>
+ </rtept>
+ <rtept lat="50.309198000" lon="8.231532000">
+ <ele>340.210000</ele>
+ <time>2009-11-06T21:32:37.533Z</time>
+ <name>RPT006</name>
+ <fix>2d</fix>
+ <sat>11</sat>
+ <hdop>0.766000</hdop>
+ </rtept>
+ <rtept lat="50.309623000" lon="8.231283000">
+ <ele>339.163000</ele>
+ <time>2009-11-06T21:32:38.534Z</time>
+ <name>RPT007</name>
+ <fix>2d</fix>
+ <sat>11</sat>
+ <hdop>0.766000</hdop>
+ </rtept>
+</rte>
+</gpx>
--- /dev/null
+38528677, 213232, 8.232662, 50.307048, 341.95, 180.227, 2, 0.766000, 11, 20091106, 0, 300
+38529696, 213233, 8.232442, 50.307475, 341.99, 179.174, 2, 0.766000, 11, 20091106, 0, 298
+38530720, 213234, 8.232223, 50.307902, 341.813, 179.203, 2, 0.832000, 10, 20091106, 0, 297
+38531752, 213235, 8.232000, 50.308332, 341.493, 181.152, 2, 0.766000, 11, 20091106, 0, 295
+38532669, 213236, 8.231770, 50.308765, 341.15, 183.765, 2, 0.766000, 11, 20091106, 0, 293
+38533696, 213237, 8.231532, 50.309198, 340.21, 183.95, 2, 0.766000, 11, 20091106, 0, 292
+38534714, 213238, 8.231283, 50.309623, 339.163, 178.342, 2, 0.766000, 11, 20091106, 0, 291
gpsbabel -i gpx -f ${TMPDIR}/${GoPalName}.im2 -o gopal -F ${TMPDIR}/${GoPalName}.tst3
compare ${TMPDIR}/${GoPalName}.tst2 ${TMPDIR}/${GoPalName}.tst3
+# Gopal with 11 fields is slightly more sane.
+gpsbabel -i gopal -f reference/gopal-11.trk -o gpx -F ${TMPDIR}/gopal-11-gpx.gpx
+compare ${TMPDIR}/gopal-11-gpx.gpx reference/gopal-11-gpx.gpx
#
# Height filter
and is simply discarded while reading. If written, there will be a time_t value from the current (computed) timestamp.
</para>
<para>
+Somehwere around Gopal 4.8 or 5.0, Electrobit added three more fields to the end of this format. They are, in order, date (which eliminates most of the silliness above), an unknonw field, and a bearing. GPSBabel now reads the date and ignores the other two. We don't yet write these three fields for compatibility with earlier versions.
+</para>
+<para>
Filtering out invalid data points is handled by the options 'clean', 'minspeed' and 'maxspeed'.
For each datapoint the speed needed to come the from the last valid point is